package test.wrc.com.app;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class LoginActivity extends BaseActivity {

    EditText username;
    EditText password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        Intent intent = getIntent();

        String name = intent.getStringExtra("username");
        Log.i(TAG, "name:" + name);

        username = (EditText) findViewById(R.id.username);
        //        username.setText(name);
        password = (EditText) findViewById(R.id.password);
        findViewById(R.id.login).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = username.getText().toString().trim();
                String pass = password.getText().toString().trim();
                Intent data = new Intent();
                data.putExtra("username", name + pass);
                setResult(RESULT_OK, data);
                finish();
            }
        });
    }

    @Override
    public void onClick(View v) {

    }


    /**
     * Activity 创建时需要初始参数写公共放法 便于管理
     *
     * @param context
     * @param data1
     * @param data2
     */
    public static void actionStart(Context context, String data1, String data2) {
        Intent intent = new Intent(context, LoginActivity.class);
        intent.putExtra("data1", data1);
        intent.putExtra("data2", data2);
        context.startActivity(intent);
    }

}
